//
//  ExecuteCell.m
//  zhiche--delivery
//
//  Created by LeeBruce on 16/5/27.
//  Copyright © 2016年 LeeBruce. All rights reserved.
//

#import "ExecuteCell.h"
#import <Masonry.h>

@implementation ExecuteCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self initSubviews];
    }
    
    return self;
}

-(void)initSubviews
{
//    __weak typeof(self) weakSelf = self;
    
    CGRect rightFrame = CGRectMake(screenWidth - screenWidth/4.0, 125 * kHeight, screenWidth/4.0, 35);
    CGRect leftFrame = CGRectMake(screenWidth /2.0, 125 * kHeight, screenWidth/4.0, 35);

    
//    //取消
//    self.cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
//
//    
//    self.cancelButton.frame = rightFrame;
//    
//    [self.cancelButton setTitle:@"取消订单" forState:UIControlStateNormal];
//    [self.cancelButton setTitleColor:BlackColor forState:UIControlStateNormal];
//    self.cancelButton.titleLabel.font = Font(15);
//    
//    [self.contentView addSubview:self.cancelButton];
//    
//    UILabel *label = [[UILabel alloc]init];
//    [self.contentView addSubview:label];
//    label.frame =  CGRectMake(CGRectGetMinX(self.cancelButton.frame) - 0.5, CGRectGetMinY(self.cancelButton.frame), 0.5, 34);
//
//    label.backgroundColor = GrayColor;
//    
//    
//    
//    //支付订金
//
//    self.topayButton = [UIButton buttonWithType:UIButtonTypeCustom];
//
//    self.topayButton.frame = leftFrame;
//    
//    [self.topayButton setTitle:@"支付订金" forState:UIControlStateNormal];
//    [self.topayButton setTitleColor:BlackColor forState:UIControlStateNormal];
//    self.topayButton.titleLabel.font = Font(15);
//    
//    
//    
//    UILabel *label1 = [[UILabel alloc]init];
////    [self.contentView addSubview:label1];
//
//    label1.frame = CGRectMake(screenWidth - screenWidth/2.0 - 0.5, CGRectGetMinY(self.cancelButton.frame), 0.5, 34);
//    label1.backgroundColor = GrayColor;
//    label1.tag = 503;
//
//    
//    
//    //支付余额
//
//    self.payLastMoneyButton = [UIButton buttonWithType:UIButtonTypeCustom];
//
//    self.payLastMoneyButton.frame = rightFrame;
//    
//    [self.payLastMoneyButton setTitle:@"支付余额" forState:UIControlStateNormal];
//    [self.payLastMoneyButton setTitleColor:BlackColor forState:UIControlStateNormal];
//    self.payLastMoneyButton.titleLabel.font = Font(15);
    
    
    self.confirmButton = [UIButton buttonWithType:UIButtonTypeCustom];
    
        self.confirmButton.frame = rightFrame;
    
        [self.confirmButton setTitle:@"确认发车" forState:UIControlStateNormal];
        [self.confirmButton setTitleColor:BlackColor forState:UIControlStateNormal];
        self.confirmButton.titleLabel.font = Font(14);
        self.confirmButton.layer.cornerRadius = 5;
        [self.contentView addSubview:self.confirmButton];
    
}

-(void)setModel:(MineOrderModel *)model
{
    if (_model != model) {
        
                    
//            if ([model.statusText isEqualToString:@"已确定"]) {
//            
//                [self.contentView addSubview:self.cancelButton];
//                [self.contentView addSubview:self.topayButton];
//
//            
//            } else {
//                [self.contentView addSubview:self.payLastMoneyButton];
//                UILabel *label = [self.contentView viewWithTag:503];
//                label.hidden = YES;
//            }

        /*
        
        //订单号
        self.orderNumberL.text = [NSString stringWithFormat:@"%@",model.waybillCode];
        //起始地
        self.startAddress.text = [NSString stringWithFormat:@"%@-%@",model.loadProvince,model.loadCity];
        
        //状态
//        self.statusLabel.text = [NSString stringWithFormat:@"%@",model.statusText];
        
        //起始时间
        
        self.startTimeL.text = [NSString stringWithFormat:@"%@",model.loadTime];
        //终止地
        self.endAddress.text = [NSString stringWithFormat:@"%@-%@",model.unloadProvince,model.unloadCity];
        
        //终止日期
        self.endTimeL.text = [NSString stringWithFormat:@"%@",model.unloadTime];
        
        //车
        NSMutableArray *array = [NSMutableArray array];
        self.carStyleL.text = @"";
        
        for (int i = 0; i < model.vehicles.count; i ++) {
            NSString *string = [NSString stringWithFormat:@"%@ %@辆",model.vehicles[i][@"brandName"],model.vehicles[i][@"amount"]];
            
            self.carStyleL.text = [self.carStyleL.text stringByAppendingString:string];
            self.carStyleL.text = [self.carStyleL.text stringByAppendingString:@"   "];
            
            [array addObject:string];
            
        }
         */
        
        
    }
}


-(NSString *)backDateWithString:(NSString *)string
{
    NSDate *nd = [NSDate dateWithTimeIntervalSince1970:[string integerValue]/1000];
    
    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
    [dateFormat setDateFormat:@"yyyy-MM-dd"];
    NSString *dateString = [dateFormat stringFromDate:nd];
    
    return dateString;
}



@end
